#pragma once
#include <string>

#ifdef _WIN32
#include <Windows.h>
#undef TRUE
#undef FALSE
#undef OPTIONAL
#undef EOF
#endif // _WIN32

namespace Basic7
{
	namespace Hash
	{
		uint32_t HashSeq(const char *_First, size_t _Count);
		inline uint32_t HashSeq(const std::string& str)
		{
			return HashSeq(str.c_str(), str.length());
		}
	}
	namespace Tools
	{
		template <class T> class Refer
		{
		public:
			Refer(T * instance) : instance_(instance) {};

			inline long AddRef() volatile
			{
#ifdef _WIN32 
				return InterlockedIncrement(&refcount);
#endif
			}
			inline long Release() volatile
			{
#ifdef _WIN32
				if (auto ret = InterlockedDecrement(&refcount))
#endif
				{
					return ret;
				}
				delete instance_;
				return 0;
			}

		protected:
			volatile long refcount = 1;
		private:
			T * instance_;
		};
	}

	

}